<?php
$servername = "localhost";
    $username = "root";
    $password = "123456";
    $dbname = "hanwei";


?>
<?php
error_reporting(E_ALL || ~E_NOTICE);
 // Session需要先启动。
 session_start();
 //判断uname和pwd是否赋值
 if(isset($_POST['name']) && isset($_POST['pwd'])){
     $name = $_POST['name'];
     $pwd = $_POST['pwd'];
     //连接数据库
     $_SESSION['logined']=1;   //判断是否已经登录的依据。
    $_SESSION['name']=$name;  //记录当前登录用户。
     $conn = new mysqli($servername, $username, $password, $dbname);
 if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
 }
 //验证内容是否与数据库的记录吻合。
 $sql = "SELECT * FROM User WHERE (user='$name') AND (password='$pwd')";
 //执行上面的sql语句并将结果集赋给result。
 $result = $conn->query($sql);
 //判断结果集的记录数是否大于0
 if ($result->num_rows > 0) {
      $_SESSION['user_account'] = $name;
      // 输出每行数据
          while($row = $result->fetch_assoc()) {
            echo "<script> alert('登录成功');parent.location.href='/920/index.php'; </script>"; 
            
         }
     } else {
          echo "<script> alert('用户名或密码错误，检查您的用户名或者密码');parent.location.href='/920/login.php'; </script>"; 
     }
     $conn->close(); 
     }

?>
<?php

 $conn=mysql_connect($servername,$username,$password) or die("error connecting") ; //连接数据库

    mysql_query("set names 'utf8'"); //数据库输出编码 应该与你的数据库编码保持一致.南昌网站建设公司百恒网络PHP工程师建议用UTF-8 国际标准编码.

    mysql_select_db($dbname); //打开数据库

	$a = mysql_fetch_array(mysql_query("SELECT * FROM info"));

	$stitle = $a['stitle'];
	$slogo = $a['slogo'];
	$surl = $a['surl'];
	$skeywords = $a['skeywords'];
	$sdescription = $a['sdescription'];
	$s_name = $a['s_name'];
	$s_phone = $a['s_phone'];
	$s_tel = $a['s_tel'];
	$s_fax = $a['s_fax'];
	$s_qq = $a['s_qq'];
	$s_email = $a['s_email'];
	$s_address = $a['s_address'];
	$scopyright = $a['scopyright'];
?>
